<!-- 博客文章教程使用 -->
<div class="toot" id="toot-container">
    <!-- Toot content will be inserted here using JavaScript -->
</div>
<h2>Comments:</h2>
<div id="comments-container">
    <!-- Comments will be inserted here using JavaScript -->
</div>

<div id="comment-info"></div>
<a href="/auth.html">Auth</a>
<div>
    <textarea id="statusInput" rows="4" cols="50" placeholder="Enter your status..."></textarea>
    <div><button id="submitBtn">Submit</button></div>
</div>

<!-- moment.js 或者 相对时间 Lately.js  -->
<script type="text/javascript" src="/js/moment.js"></script>
<script type="text/javascript" src="/js/mastodon.js"></script>

<script>
    // !!!IMPORTANT!!! Bot  Mastodon access token ONLY read:statuses 
    const accessToken = "{{ .Get 1 | default .Site.Params.bot_token }}"; // 配置文件设置
    // https://example.com/@tom/statuses/xxxx
    const statusURL = "{{ .Get 0 }}"

    function commentInfo(text) {
        document.getElementById('comment-info').textContent = text;
        console.log(text);
    }
    const bot = new MastodonBot(statusURL, accessToken)
    // Login User Info
    const myAccount = new MastodonUserManager(localStorage.getItem("MASTODON_URL"), localStorage.getItem("MASTODON_ACCESS_TOKEN"), localStorage.getItem("MASTODON_ACCOUNT_URL"));
    // Fetch and display the toot and comments when the page loads
    // moment : timeFmt
    const comments = new MastodonComment(bot, myAccount, commentInfo, moment)
    comments.init();

</script>